package cn.school.mybatis.controller;

import cn.school.mybatis.pojo.Admin;
import cn.school.mybatis.pojo.Grade;
import cn.school.mybatis.service.GradeService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/s_grade")
public class GradeController {
    @Autowired
    private GradeService gradeService;

    @RequestMapping("/gerGrade")
    public void sayHi(HttpServletResponse resp) throws IOException {

        PrintWriter out = resp.getWriter();
        List<Grade> list = gradeService.searchAll();

        String gradeJSON= JSON.toJSONString(list);
        resp.setContentType("application/json;charset=UTF-8");
        resp.getWriter().print(gradeJSON);
    }

}
